\(\int \frac {(c+d \tan (e+f x))^2}{a+i a \tan (e+f x)} \, dx\) [1074]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [F(-2)]
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 28, antiderivative size = 75 \[ \int \frac {(c+d \tan (e+f x))^2}{a+i a \tan (e+f x)} \, dx=\frac {\left (c^2-2 i c d+d^2\right ) x}{2 a}+\frac {i d^2 \log (\cos (e+f x))}{a f}+\frac {i (c+i d)^2}{2 f (a+i a \tan (e+f x))} \]

[Out]

1/2*(c^2-2*I*c*d+d^2)*x/a+I*d^2*ln(cos(f*x+e))/a/f+1/2*I*(c+I*d)^2/f/(a+I*a*tan(f*x+e))

Rubi [A] (verified)

Time = 0.10 (sec) , antiderivative size = 75, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.071, Rules used = {3621, 3556} \[ \int \frac {(c+d \tan (e+f x))^2}{a+i a \tan (e+f x)} \, dx=\frac {x \left (c^2-2 i c d+d^2\right )}{2 a}+\frac {i (c+i d)^2}{2 f (a+i a \tan (e+f x))}+\frac {i d^2 \log (\cos (e+f x))}{a f} \]

[In]

Int[(c + d*Tan[e + f*x])^2/(a + I*a*Tan[e + f*x]),x]

[Out]

((c^2 - (2*I)*c*d + d^2)*x)/(2*a) + (I*d^2*Log[Cos[e + f*x]])/(a*f) + ((I/2)*(c + I*d)^2)/(f*(a + I*a*Tan[e +
f*x]))

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3621

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^2, x_Symbol] :> Simp[(
-b)*(a*c + b*d)^2*((a + b*Tan[e + f*x])^m/(2*a^3*f*m)), x] + Dist[1/(2*a^2), Int[(a + b*Tan[e + f*x])^(m + 1)*
Simp[a*c^2 - 2*b*c*d + a*d^2 - 2*b*d^2*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a
*d, 0] && LeQ[m, -1] && EqQ[a^2 + b^2, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {i (c+i d)^2}{2 f (a+i a \tan (e+f x))}+\frac {\int \left (a \left (c^2-2 i c d+d^2\right )-2 i a d^2 \tan (e+f x)\right ) \, dx}{2 a^2} \\ & = \frac {\left (c^2-2 i c d+d^2\right ) x}{2 a}+\frac {i (c+i d)^2}{2 f (a+i a \tan (e+f x))}-\frac {\left (i d^2\right ) \int \tan (e+f x) \, dx}{a} \\ & = \frac {\left (c^2-2 i c d+d^2\right ) x}{2 a}+\frac {i d^2 \log (\cos (e+f x))}{a f}+\frac {i (c+i d)^2}{2 f (a+i a \tan (e+f x))} \\ \end{align*}

Mathematica [A] (verified)

Time = 1.56 (sec) , antiderivative size = 143, normalized size of antiderivative = 1.91 \[ \int \frac {(c+d \tan (e+f x))^2}{a+i a \tan (e+f x)} \, dx=-\frac {i \left ((c+i d) \left (\left (c^2-2 i c d+3 d^2\right ) \log (i-\tan (e+f x))-(c-i d)^2 \log (i+\tan (e+f x))\right )+2 d^2 (-3 i c+d) \tan (e+f x)-2 i d^3 \tan ^2(e+f x)+\frac {2 i (c+d \tan (e+f x))^3}{-i+\tan (e+f x)}\right )}{4 a (c+i d) f} \]

[In]

Integrate[(c + d*Tan[e + f*x])^2/(a + I*a*Tan[e + f*x]),x]

[Out]

((-1/4*I)*((c + I*d)*((c^2 - (2*I)*c*d + 3*d^2)*Log[I - Tan[e + f*x]] - (c - I*d)^2*Log[I + Tan[e + f*x]]) + 2
*d^2*((-3*I)*c + d)*Tan[e + f*x] - (2*I)*d^3*Tan[e + f*x]^2 + ((2*I)*(c + d*Tan[e + f*x])^3)/(-I + Tan[e + f*x
])))/(a*(c + I*d)*f)

Maple [A] (verified)

Time = 0.35 (sec) , antiderivative size = 126, normalized size of antiderivative = 1.68

method result size
risch \(-\frac {i x c d}{a}+\frac {c^{2} x}{2 a}+\frac {3 x \,d^{2}}{2 a}-\frac {{\mathrm e}^{-2 i \left (f x +e \right )} c d}{2 a f}+\frac {i {\mathrm e}^{-2 i \left (f x +e \right )} c^{2}}{4 a f}-\frac {i {\mathrm e}^{-2 i \left (f x +e \right )} d^{2}}{4 a f}+\frac {2 d^{2} e}{a f}+\frac {i d^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )}{a f}\) \(126\)
derivativedivides \(-\frac {i c d \arctan \left (\tan \left (f x +e \right )\right )}{f a}+\frac {c^{2} \arctan \left (\tan \left (f x +e \right )\right )}{2 f a}-\frac {i d^{2} \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2 f a}+\frac {d^{2} \arctan \left (\tan \left (f x +e \right )\right )}{2 f a}+\frac {i c d}{f a \left (\tan \left (f x +e \right )-i\right )}+\frac {c^{2}}{2 f a \left (\tan \left (f x +e \right )-i\right )}-\frac {d^{2}}{2 f a \left (\tan \left (f x +e \right )-i\right )}\) \(145\)
default \(-\frac {i c d \arctan \left (\tan \left (f x +e \right )\right )}{f a}+\frac {c^{2} \arctan \left (\tan \left (f x +e \right )\right )}{2 f a}-\frac {i d^{2} \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2 f a}+\frac {d^{2} \arctan \left (\tan \left (f x +e \right )\right )}{2 f a}+\frac {i c d}{f a \left (\tan \left (f x +e \right )-i\right )}+\frac {c^{2}}{2 f a \left (\tan \left (f x +e \right )-i\right )}-\frac {d^{2}}{2 f a \left (\tan \left (f x +e \right )-i\right )}\) \(145\)

[In]

int((c+d*tan(f*x+e))^2/(a+I*a*tan(f*x+e)),x,method=_RETURNVERBOSE)

[Out]

-I*x/a*c*d+1/2*c^2*x/a+3/2*x/a*d^2-1/2/a/f*exp(-2*I*(f*x+e))*c*d+1/4*I/a/f*exp(-2*I*(f*x+e))*c^2-1/4*I/a/f*exp
(-2*I*(f*x+e))*d^2+2*d^2/a/f*e+I*d^2/a/f*ln(exp(2*I*(f*x+e))+1)

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 84, normalized size of antiderivative = 1.12 \[ \int \frac {(c+d \tan (e+f x))^2}{a+i a \tan (e+f x)} \, dx=\frac {{\left (2 \, {\left (c^{2} - 2 i \, c d + 3 \, d^{2}\right )} f x e^{\left (2 i \, f x + 2 i \, e\right )} + 4 i \, d^{2} e^{\left (2 i \, f x + 2 i \, e\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + i \, c^{2} - 2 \, c d - i \, d^{2}\right )} e^{\left (-2 i \, f x - 2 i \, e\right )}}{4 \, a f} \]

[In]

integrate((c+d*tan(f*x+e))^2/(a+I*a*tan(f*x+e)),x, algorithm="fricas")

[Out]

1/4*(2*(c^2 - 2*I*c*d + 3*d^2)*f*x*e^(2*I*f*x + 2*I*e) + 4*I*d^2*e^(2*I*f*x + 2*I*e)*log(e^(2*I*f*x + 2*I*e) +
 1) + I*c^2 - 2*c*d - I*d^2)*e^(-2*I*f*x - 2*I*e)/(a*f)

Sympy [A] (verification not implemented)

Time = 0.24 (sec) , antiderivative size = 170, normalized size of antiderivative = 2.27 \[ \int \frac {(c+d \tan (e+f x))^2}{a+i a \tan (e+f x)} \, dx=\begin {cases} \frac {\left (i c^{2} - 2 c d - i d^{2}\right ) e^{- 2 i e} e^{- 2 i f x}}{4 a f} & \text {for}\: a f e^{2 i e} \neq 0 \\x \left (- \frac {c^{2} - 2 i c d + 3 d^{2}}{2 a} + \frac {\left (c^{2} e^{2 i e} + c^{2} - 2 i c d e^{2 i e} + 2 i c d + 3 d^{2} e^{2 i e} - d^{2}\right ) e^{- 2 i e}}{2 a}\right ) & \text {otherwise} \end {cases} + \frac {i d^{2} \log {\left (e^{2 i f x} + e^{- 2 i e} \right )}}{a f} + \frac {x \left (c^{2} - 2 i c d + 3 d^{2}\right )}{2 a} \]

[In]

integrate((c+d*tan(f*x+e))**2/(a+I*a*tan(f*x+e)),x)

[Out]

Piecewise(((I*c**2 - 2*c*d - I*d**2)*exp(-2*I*e)*exp(-2*I*f*x)/(4*a*f), Ne(a*f*exp(2*I*e), 0)), (x*(-(c**2 - 2
*I*c*d + 3*d**2)/(2*a) + (c**2*exp(2*I*e) + c**2 - 2*I*c*d*exp(2*I*e) + 2*I*c*d + 3*d**2*exp(2*I*e) - d**2)*ex
p(-2*I*e)/(2*a)), True)) + I*d**2*log(exp(2*I*f*x) + exp(-2*I*e))/(a*f) + x*(c**2 - 2*I*c*d + 3*d**2)/(2*a)

Maxima [F(-2)]

Exception generated. \[ \int \frac {(c+d \tan (e+f x))^2}{a+i a \tan (e+f x)} \, dx=\text {Exception raised: RuntimeError} \]

[In]

integrate((c+d*tan(f*x+e))^2/(a+I*a*tan(f*x+e)),x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: expt: undefined: 0 to a negative exponent.

Giac [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 123 vs. \(2 (61) = 122\).

Time = 0.48 (sec) , antiderivative size = 123, normalized size of antiderivative = 1.64 \[ \int \frac {(c+d \tan (e+f x))^2}{a+i a \tan (e+f x)} \, dx=-\frac {\frac {{\left (-i \, c^{2} - 2 \, c d + i \, d^{2}\right )} \log \left (\tan \left (f x + e\right ) + i\right )}{a} + \frac {{\left (i \, c^{2} + 2 \, c d + 3 i \, d^{2}\right )} \log \left (\tan \left (f x + e\right ) - i\right )}{a} + \frac {-i \, c^{2} \tan \left (f x + e\right ) - 2 \, c d \tan \left (f x + e\right ) - 3 i \, d^{2} \tan \left (f x + e\right ) - 3 \, c^{2} - 2 i \, c d - d^{2}}{a {\left (\tan \left (f x + e\right ) - i\right )}}}{4 \, f} \]

[In]

integrate((c+d*tan(f*x+e))^2/(a+I*a*tan(f*x+e)),x, algorithm="giac")

[Out]

-1/4*((-I*c^2 - 2*c*d + I*d^2)*log(tan(f*x + e) + I)/a + (I*c^2 + 2*c*d + 3*I*d^2)*log(tan(f*x + e) - I)/a + (
-I*c^2*tan(f*x + e) - 2*c*d*tan(f*x + e) - 3*I*d^2*tan(f*x + e) - 3*c^2 - 2*I*c*d - d^2)/(a*(tan(f*x + e) - I)
))/f

Mupad [B] (verification not implemented)

Time = 6.20 (sec) , antiderivative size = 112, normalized size of antiderivative = 1.49 \[ \int \frac {(c+d \tan (e+f x))^2}{a+i a \tan (e+f x)} \, dx=-\frac {\frac {c\,d}{a}-\frac {c^2\,1{}\mathrm {i}}{2\,a}+\frac {d^2\,1{}\mathrm {i}}{2\,a}}{f\,\left (1+\mathrm {tan}\left (e+f\,x\right )\,1{}\mathrm {i}\right )}-\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )-\mathrm {i}\right )\,\left (c^2-c\,d\,2{}\mathrm {i}+3\,d^2\right )\,1{}\mathrm {i}}{4\,a\,f}+\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (c^2\,1{}\mathrm {i}+2\,c\,d-d^2\,1{}\mathrm {i}\right )}{4\,a\,f} \]

[In]

int((c + d*tan(e + f*x))^2/(a + a*tan(e + f*x)*1i),x)

[Out]

(log(tan(e + f*x) + 1i)*(2*c*d + c^2*1i - d^2*1i))/(4*a*f) - (log(tan(e + f*x) - 1i)*(c^2 - c*d*2i + 3*d^2)*1i
)/(4*a*f) - ((d^2*1i)/(2*a) - (c^2*1i)/(2*a) + (c*d)/a)/(f*(tan(e + f*x)*1i + 1))